package com.knife.hospital.controller;

import com.knife.hospital.config.BaseResponse;
import com.knife.hospital.entity.OrderPO;
import com.knife.hospital.model.order.OrderRequest;
import com.knife.hospital.model.order.UserOrderResponse;
import com.knife.hospital.service.order.UserOrderService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Controller
@CrossOrigin
@ResponseBody
@BaseResponse
@RestController
public class UserOrderController {
    @Resource
    private UserOrderService userOrderService;

    @GetMapping(value = "api/order/getCommonUserOrder/{id}")
    public List<UserOrderResponse> getUserOrders(@PathVariable("id") int id){
        return userOrderService.getUserOrders(id);
    }

    @PostMapping(value = "api/order/order")
    public OrderPO applyOrder(@RequestBody OrderRequest orderRequest) {
        return userOrderService.applyOrder(orderRequest);
    }
}
